//
//  OWWVCBaseAnimation.m
//  Ohwawa
//
//  Created by jing ling on 2017/12/17.
//  Copyright © 2017年 changyi. All rights reserved.
//

#import "OWWVCBaseAnimation.h"

@interface OWWVCBaseAnimation()
@property (nonatomic, weak) id <UIViewControllerContextTransitioning>transitonContext;
@property (nonatomic, weak) UIViewController *fromVC;
@property (nonatomic, weak) UIViewController *toVC;
@property (nonatomic, weak) UIView *containerView;
@end

@implementation OWWVCBaseAnimation
- (instancetype)init {
    self = [super init];
    if (self) {
        _transitionDuration = 0.2f;
    }
    return self;
}

- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
    return _transitionDuration;
}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
    self.fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    self.toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    self.containerView = [transitionContext containerView];
    self.transitonContext = transitionContext;
    [self animateTransitionEvent];
}

- (void)animateTransitionEvent {
}

- (void)completeTransition {
    [self.transitonContext completeTransition:!self.transitonContext.transitionWasCancelled];
}
@end
